<html>
<head><meta charset="utf-8"><title>assoc_items · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html">assoc_items</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="159741267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159741267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159741267">(Mar 01 2019 at 19:24)</a>:</h4>
<p>When I see something like</p>
<blockquote>
<p>path segment "new" resolved to non-module Struct(Struct { id: StructId(0) }), but is not last</p>
</blockquote>
<p>What does the <code>but is not last</code> refer to?</p>



<a name="159741964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159741964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159741964">(Mar 01 2019 at 19:34)</a>:</h4>
<p>during resolution</p>



<a name="159742441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159742441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159742441">(Mar 01 2019 at 19:41)</a>:</h4>
<p>I think there's an off-by-one in that log message ;) so you have e.g. <code>Foo::new()</code>, and it's saying that <code>Foo</code> resolved to some struct, not a module, so it's stopping the resolution at that point (if this happens for an import, it's an error, but in an expression we can continue resolving it during type inference)</p>



<a name="159742687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159742687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159742687">(Mar 01 2019 at 19:44)</a>:</h4>
<p>I was wondering that too</p>



<a name="159742702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159742702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159742702">(Mar 01 2019 at 19:45)</a>:</h4>
<p>I'm basically trying to resolve <code>Foo::new()</code></p>



<a name="159742762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159742762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159742762">(Mar 01 2019 at 19:45)</a>:</h4>
<p>well figure out why it doesn't resolve</p>



<a name="159744277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159744277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159744277">(Mar 01 2019 at 20:03)</a>:</h4>
<p>It's handled during type inference, like method calls. We just don't handle it for goto def. Probably, we need another side table during type inference where we write resolutions of associated items, and then use that for goto def (I wrote a bit about that here: <a href="https://github.com/rust-analyzer/rust-analyzer/issues/832#issuecomment-463751288" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/832#issuecomment-463751288">https://github.com/rust-analyzer/rust-analyzer/issues/832#issuecomment-463751288</a> )</p>



<a name="159745315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159745315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159745315">(Mar 01 2019 at 20:15)</a>:</h4>
<p>So we need a side table for type inference or one for goto def?</p>



<a name="159748662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159748662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159748662">(Mar 01 2019 at 21:00)</a>:</h4>
<p>A side table for type inference to write information that goto def can then use ;)</p>



<a name="159748674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159748674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159748674">(Mar 01 2019 at 21:00)</a>:</h4>
<p>(and by side table I really just mean a hash map, like the ones for method and field resolutions)</p>



<a name="159749066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159749066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159749066">(Mar 01 2019 at 21:06)</a>:</h4>
<p>Yep. I have one going from ExprId to Function but <code>infer_expr</code> doesn't seem to get called</p>



<a name="159749149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159749149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159749149">(Mar 01 2019 at 21:07)</a>:</h4>
<p>Maybe we need to use inference if <code>name_ref.syntax().parent().and_then(ast::PathSegment::cast)</code></p>



<a name="159749151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159749151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159749151">(Mar 01 2019 at 21:08)</a>:</h4>
<p>in goto def</p>



<a name="159750470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159750470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159750470">(Mar 01 2019 at 21:25)</a>:</h4>
<p><code>reference_definition</code> calls type inference if it sees a method or field access, it should probably do the same if it can't resolve a path</p>



<a name="159750633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159750633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159750633">(Mar 01 2019 at 21:27)</a>:</h4>
<p>Ok i'll try it if name resolution fails</p>



<a name="159751014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159751014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159751014">(Mar 01 2019 at 21:33)</a>:</h4>
<p>so infer_expr doesn't really know anything about the "receiver" since this is a call expr and not really a method right?</p>



<a name="159751897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159751897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159751897">(Mar 01 2019 at 21:44)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> I'm assuming that I write to the hash table in <code>infer_expr</code> if we're looking at <code>Expr:Call</code>. How do I get the <code>Function</code> I need? I think I need to find an <code>ImplBlock::Method</code>?</p>



<a name="159751933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159751933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159751933">(Mar 01 2019 at 21:44)</a>:</h4>
<p>I think you write to the hash table when you're looking at the <code>Expr::Path</code> already</p>



<a name="159751962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159751962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159751962">(Mar 01 2019 at 21:45)</a>:</h4>
<p>it might be an associated constant as well, it doesn't really matter if it's called or what else is done with it afterwards</p>



<a name="159752088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752088">(Mar 01 2019 at 21:47)</a>:</h4>
<p>so basically at the end of <code>infer_path_expr</code>, you may have a <code>Resolution::Def(some_module_def)</code>, and then you can save that</p>



<a name="159752119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752119">(Mar 01 2019 at 21:47)</a>:</h4>
<p>by the way, I just notice that we basically convert the <code>ImplItem::Method</code> into a <code>ModuleDef::Function</code> there, which feels... weird</p>



<a name="159752184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752184">(Mar 01 2019 at 21:48)</a>:</h4>
<p>but I guess if you just interpret <code>ModuleDef</code> as 'things that could be in a module' as opposed to 'things that are in a module', it's fine</p>



<a name="159752578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752578">(Mar 01 2019 at 21:53)</a>:</h4>
<p>Should I be saving the path instead of the expr? I guess this is more of a path to associated thing map</p>



<a name="159752590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752590">(Mar 01 2019 at 21:53)</a>:</h4>
<p>sorry: would it make more sense that the path is the key</p>



<a name="159752807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752807">(Mar 01 2019 at 21:56)</a>:</h4>
<p>I think in some weird edge cases the same paths might resolve to different items even in the same function...</p>



<a name="159752842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752842">(Mar 01 2019 at 21:56)</a>:</h4>
<p>on the other hand, we ideally want all the intermediate resolutions as well</p>



<a name="159752858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752858">(Mar 01 2019 at 21:57)</a>:</h4>
<p>still, it should be keyed on the expression I think</p>



<a name="159752883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752883">(Mar 01 2019 at 21:57)</a>:</h4>
<p>well the issue is that the expression is not acccessible from that point</p>



<a name="159752977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752977">(Mar 01 2019 at 21:58)</a>:</h4>
<p>and the other caller <code>infer_pat</code> doesn't have one passed in either</p>



<a name="159752989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159752989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159752989">(Mar 01 2019 at 21:58)</a>:</h4>
<p>oh, I think it should be fine to just pass the <code>ExprId</code> to <code>infer_path_expr</code></p>



<a name="159753071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159753071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159753071">(Mar 01 2019 at 21:59)</a>:</h4>
<p>oh, it's called by pattern inference as well, right...</p>



<a name="159753076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159753076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159753076">(Mar 01 2019 at 21:59)</a>:</h4>
<p>yeah</p>



<a name="159753155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159753155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159753155">(Mar 01 2019 at 22:00)</a>:</h4>
<p>we do want to save the resolution in the pattern case as well</p>



<a name="159753292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159753292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159753292">(Mar 01 2019 at 22:02)</a>:</h4>
<p>we might return the resolved item as well as the type... or pass a callback to <code>infer_path_expr</code> that writes the resolution to the right place... or pass some enum wrapping <code>ExprId</code> or <code>PatId</code>... not sure what the nicest approach is</p>



<a name="159756456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159756456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159756456">(Mar 01 2019 at 22:49)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> I chose the latter for now</p>



<a name="159758477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159758477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159758477">(Mar 01 2019 at 23:21)</a>:</h4>
<p>think i have something that works for associated functions</p>



<a name="159759550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/159759550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#159759550">(Mar 01 2019 at 23:37)</a>:</h4>
<p>PR is up</p>



<a name="160094392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160094392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160094392">(Mar 06 2019 at 13:22)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> we don't currently do anything with that <code>PatId</code>. should we right now?</p>



<a name="160094614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160094614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160094614">(Mar 06 2019 at 13:25)</a>:</h4>
<p>I guess if you use an associated constant in a pattern, we should?</p>



<a name="160094822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160094822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160094822">(Mar 06 2019 at 13:28)</a>:</h4>
<p>Are associated constants even allowed in patterns? How would you check pattern disjointess?</p>



<a name="160095841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160095841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160095841">(Mar 06 2019 at 13:41)</a>:</h4>
<p>inherent associated constants don't have that problem <span class="user-mention" data-user-id="133169">@matklad</span> <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=9881a070f75f0458cdb51f1513f2a2dc" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=9881a070f75f0458cdb51f1513f2a2dc">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=9881a070f75f0458cdb51f1513f2a2dc</a></p>



<a name="160096168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160096168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160096168">(Mar 06 2019 at 13:45)</a>:</h4>
<p>looks like that answers the question</p>



<a name="160098051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160098051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160098051">(Mar 06 2019 at 14:07)</a>:</h4>
<p>associated consts of a trait do indeed not work in patterns</p>



<a name="160098150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160098150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160098150">(Mar 06 2019 at 14:08)</a>:</h4>
<p>Hm, they <strong>do</strong> work? <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8e3658e31e3c73457a827151b59527b9" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8e3658e31e3c73457a827151b59527b9">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8e3658e31e3c73457a827151b59527b9</a></p>



<a name="160099410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160099410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160099410">(Mar 06 2019 at 14:22)</a>:</h4>
<p>Yeah if the self type is known, I meant something like this: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=1f70f60dbd38fce55af7159795fca16b" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=1f70f60dbd38fce55af7159795fca16b">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=1f70f60dbd38fce55af7159795fca16b</a></p>



<a name="160103078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160103078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160103078">(Mar 06 2019 at 15:04)</a>:</h4>
<p>So in the match we're actually in a <code>PathPat</code> not a <code>Pat</code>. I can't seem to get the <code>PatId</code> from the <code>PathPat</code></p>



<a name="160111907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160111907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160111907">(Mar 06 2019 at 16:41)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/942" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/942">https://github.com/rust-analyzer/rust-analyzer/pull/942</a></p>



<a name="160112299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160112299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160112299">(Mar 06 2019 at 16:46)</a>:</h4>
<p>It will also give information on associated functions but I think that should be correct even if the compiler rejects it</p>



<a name="160114470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160114470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160114470">(Mar 06 2019 at 17:13)</a>:</h4>
<p><span class="user-mention" data-user-id="203366">@Jeremy Kolb</span> there's <code>From&lt;PathPat&gt; for </code>Pat` impl</p>



<a name="160126677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160126677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160126677">(Mar 06 2019 at 19:30)</a>:</h4>
<p>That's on the ast side. I don't think it helps</p>



<a name="160126975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160126975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160126975">(Mar 06 2019 at 19:33)</a>:</h4>
<p>the <code>PathPat</code> you have there is an <code>ast::PathPat</code>, right? you can turn that into an <code>ast::Pat</code> and get the <code>PatId</code> from the body source map (pretty much like it's done in the expr case)</p>



<a name="160127114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160127114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160127114">(Mar 06 2019 at 19:34)</a>:</h4>
<p>ah right. i missed that</p>



<a name="160127644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/assoc_items/near/160127644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/assoc_items.html#160127644">(Mar 06 2019 at 19:41)</a>:</h4>
<p>much better</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>